from selenium import webdriver
from selenium.webdriver.common.keys import Keys

from time import sleep

from m_login import login, logOut
from m_quickOrder import addPn2Cart

options = webdriver.ChromeOptions()

# 忽略无用的日志
options.add_experimental_option(
    "excludeSwitches", ['enable-automation', 'enable-logging'])
# 创建浏览器实例
driver = webdriver.Chrome(options=options)
# 打开网页
driver.get("http://localhost:3100/#/login")

# 只有页面完全 onLoad 才会执行以下脚本

# 检测浏览器标题中含有 'Login'
driver.implicitly_wait(10)


def getOrder():
    print('''
    order   |   operate
    0       |   log out
    1       |   login
    2       |   add 
    3       |   confirm
    q       |   quit driver
    ''')
    order = input('Order:')
    if order == 'q':
        driver.quit()
    elif order == '0':
        logOut(driver)
        getOrder()
    elif order == '1':
        login(driver)
        getOrder()
    elif order == '2':
        addPn2Cart(driver)
        getOrder()


getOrder()
